package com.aidex.biz.service.impl;

import com.aidex.biz.domain.CouponInfo;
import com.aidex.biz.mapper.CouponInfoMapper;
import com.aidex.biz.service.CouponInfoService;
import com.aidex.common.annotation.DataScope;
import com.aidex.common.core.service.BaseServiceImpl;
import com.aidex.common.utils.NumberUtils;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 优惠券信息Service业务层处理
 * @author sean
 * @email 2074844820@qq.com
 * @date 2023-07-02
 */
@Service
@Transactional(readOnly = true)
public class CouponInfoServiceImpl extends BaseServiceImpl<CouponInfoMapper, CouponInfo> implements CouponInfoService
{
    private static final Logger log = LoggerFactory.getLogger(CouponInfoServiceImpl.class);

    /**
     * 获取单条数据
     * @param couponInfo 优惠券信息
     * @return 优惠券信息
     */
    @Override
    public CouponInfo get(CouponInfo couponInfo)
    {
        CouponInfo dto = super.get(couponInfo);
        return dto;
    }

    /**
     * 获取单条数据
     * @param id 优惠券信息id
     * @return 优惠券信息
     */
    @Override
    public CouponInfo get(String id)
    {
        CouponInfo dto = super.get(id);
        return dto;
    }


    /**
     * 查询优惠券信息列表
     * @param couponInfo 优惠券信息
     * @return 优惠券信息
     */
    @Override
    @DataScope(userAlias = "a",deptAlias = "a")
    public List<CouponInfo> findList(CouponInfo couponInfo)
    {
        return super.findList(couponInfo);
    }

    /**
     * 分页查询优惠券信息列表
     * @param couponInfo 优惠券信息
     * @return 优惠券信息
     */
    @Override
    @DataScope(userAlias = "a",deptAlias = "a")
    public PageInfo<CouponInfo> findPage(CouponInfo couponInfo)
    {
        return super.findPage(couponInfo);
    }

    /**
     * 保存优惠券信息
     * @param couponInfo
     * @return 结果
     */
    @Override
    public boolean save(CouponInfo couponInfo)
    {
        return super.save(couponInfo);
    }


    /**
     * 删除优惠券信息信息
     * @param couponInfo
     * @return 结果
     */
    @Override
    public boolean remove(CouponInfo couponInfo)
    {
        return super.remove(couponInfo);
    }

    /**
     * 批量删除优惠券信息
     * @param ids 需要删除的优惠券信息ID
     * @return 结果
     */
    @Transactional(readOnly = false)
    @Override
    public int deleteCouponInfoByIds(String[] ids)
    {
        return mapper.deleteCouponInfoByIds(ids);
    }

    /**
     * 获取最大编号
     * @param couponInfo 优惠券信息
     * @return 结果
     */
    @Override
    public int findMaxSort(CouponInfo couponInfo)
    {
        return NumberUtils.nextOrder(mapper.findMaxSort(couponInfo));
    }

    @Override
    @Transactional(readOnly = false)
    public Integer updateIsGuoQi() {
        return mapper.updateIsGuoQi();
    }
}
